package com.alks.function.controller.web;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.WebLogger;
import com.alks.common.utils.excelUtils.BizAssertUtils;
import com.alks.entity.data.entity.webPay.FinancePayable;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.service.web.pay.PcPayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author:hxl
 * @create: 2024-11-22 16:17
 * @Description:
 */

@ApiRestController("/finance/receivable")
@Api(tags = {"应付对账", "应付结算"})
public class PcFinancePayableController {
    @Autowired
    private PcPayService pcPayService;

    @PostMapping({"/aoa/payable/list"})
    @ApiOperation(value = "应付对账列表", tags = {"应付对账"})
    @WebLogger
    public ResponseInfo receivableAoaList(@RequestBody FinancePayable financePayable) {
        return pcPayService.receivableAoaList(financePayable);
    }

    @PostMapping({"/aoa/update/aoaDate"})
    @ApiOperation(value = "填充", tags = {"应付对账"})
    @WebLogger
    public ResponseInfo updateAoaDate(@RequestParam String aoaDate, @RequestBody List<FinancePayable> records) {
        return pcPayService.updateAoaDate(aoaDate, records);
    }

    //数量检核
    @PostMapping({"/aoa/update/aoaQtyY"})
    @ApiOperation(value = "数量检核", tags = {"应付对账"})
    @WebLogger
    public ResponseInfo updateAoaQtyY(@RequestBody List<FinancePayable> records) {
        BizAssertUtils.notEmpty(records, "未选择任何记录!");
        return pcPayService.updateAoaQtyY(records);
    }
    //取消数量检核

    @PostMapping({"/aoa/update/aoaQtyN"})
    @ApiOperation(value = "取消数量检核", tags = {"应付对账"})
    @WebLogger
    public ResponseInfo updateAoaQtyN(@RequestBody List<FinancePayable> records) {
        BizAssertUtils.notEmpty(records, "未选择任何记录!");
        return pcPayService.updateAoaQtyN(records);
    }

    @PostMapping({"/aoa/update/aoaCfmN"})
    @ApiOperation(value = "取消检核", tags = {"应付对账"})
    @WebLogger
    public ResponseInfo updateAoaCfmN(@RequestBody List<FinancePayable> records) {
        BizAssertUtils.notEmpty(records, "未选择任何记录!");
        return pcPayService.updateAoaCfmN(records);
    }

    @PostMapping({"/aoa/update/aoaCfmY"})
    @ApiOperation(value = "检核", tags = {"应付对账"})
    @WebLogger
    public ResponseInfo updateAoaCfmY(@RequestBody List<FinancePayable> records) {
        BizAssertUtils.notEmpty(records, "未选择任何记录!");
        return pcPayService.updateAoaCfmY(records);
    }

    @PostMapping({"/aoa/download"})
    @ApiOperation(value = "导出", tags = {"应付对账"})
    @WebLogger
    public void downloadAoa(HttpServletResponse response, @RequestBody FinancePayable financePayable) throws IOException {
        pcPayService.downloadAoa(response, financePayable);
    }

    @PostMapping({"/payable/list"})
    @ApiOperation(value = "应付结算列表", tags = {"应付结算"})
    @WebLogger
    public ResponseInfo payableList(@RequestBody FinancePayable financePayable) {
        return pcPayService.payableList(financePayable);
    }

    @PostMapping({"/payable/download"})
    @ApiOperation(value = "应付结算导出", tags = {"应付结算"})
    @WebLogger
    public void downloadPayable(HttpServletResponse response, @RequestBody FinancePayable financePayable) throws IOException {
        pcPayService.downloadPayable(response, financePayable);
    }

    @PostMapping({"/detail/list"})
    @ApiOperation(value = "应付结算详情列表", tags = {"应付结算"})
    @WebLogger
    public ResponseInfo payableDetailList(@RequestBody FinancePayable financePayable) {
        return pcPayService.payableDetailList(financePayable);
    }

    @PostMapping({"/addDetail"})
    @ApiOperation(value = "付款确认", tags = {"应付结算"})
    @WebLogger
    public ResponseInfo addDetail(@RequestBody List<FinancePayable> financePayable) {
        return pcPayService.addDetail1(financePayable);
    }

    @PostMapping({"/deleteDetail"})
    @ApiOperation(value = "删除财务明细", tags = {"应付结算"})
    @WebLogger
    public ResponseInfo deleteDetail(@RequestBody FinancePayable financePayable) {
        return pcPayService.deleteDetail1(financePayable);
    }

    @PostMapping({"/cfm"})
    @ApiOperation(value = "检核", tags = {"应付结算"})
    @WebLogger
    public ResponseInfo updateCfmFlag(@RequestParam String payNo, @RequestParam String cfmFlag) {
        return pcPayService.updateCfmFlag(payNo, cfmFlag);
    }

    @PostMapping({"/updateRemark"})
    @ApiOperation(value = "修改备注", tags = {"应付结算"})
    @WebLogger
    public ResponseInfo updateRemark(@RequestParam String payNo, @RequestParam String remark) {
        return pcPayService.updateRemark1(payNo, remark);
    }
}